// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import App from './App'
import router from './router'

//  引入vuex全局管理
import Vuex from 'vuex'
//  图片懒加载插件
import VueLazyLoad from 'vue-lazyload'
//  滚动插件
import infiniteScroll from 'vue-infinite-scroll'

//  定义全局过滤器
import {currency} from './util/currency'

Vue.config.productionTip = false
Vue.use(VueLazyLoad,{
  loading:"/static/loading-svg/loading-bars.svg"
})
Vue.use(infiniteScroll)
Vue.use(Vuex)

Vue.filter("currency",currency)


//  定义vuex对象
const store = new Vuex.Store({
  state:{
    nickName: '',
    cartCount: 0
  },
  mutations: {
    updataUserInfo(state,nickName) {
      state.nickName = nickName;
    },
    updataCartCount(state,cartCount) {
      state.cartCount += cartCount
    },
    initCartCount(state,cartCount) {
      state.cartCount = cartCount
    }
  }
})
/* eslint-disable no-new */
new Vue({
  el: '#app',
  router,
  store,
  render: h => h(App)
  // components: { App },
  // template: '<App/>'
})
